<?php

class DBMPostgreSqlConnection extends DBMConnection {
	public function connect(){
		// try to connect
 		$connectstr = sprintf("host=%s port=5432 dbname=%s user=%s password=%s", $this->getHost(), $this->getDatabase(), $this->getUsername(), $this->getPassword());
 		$connection = @pg_connect($connectstr);
 		
 		// check the connection
 		if(!$connection){
 			throw new Exception("Impossible to open a connection with the host '" . $this->getHost(). ". Please check the options!");
 		}
	}
	public function disconnect(){
		
	}
	public function runQuery($sql){
		$result = @pg_query($this->getLink(), $sql);
		if(!$result){
			$this->setErrors($this->getErrors() + 1);
			throw new Exception("PostgreSQL query error: " . pg_errormessage($this->getLink()));
		} else {
			$this->setQueries($this->getQueries() + 1);
			return $result;
		}
	}
	public function executeSelect(DBMCommand $command){
		
	}
}

?>
